package com.visionblue.business.ship.model.api

import android.util.Log
import com.visionblue.business.ship.model.repository.DeviceInfoRepository
import okhttp3.Interceptor
import okhttp3.Response
import org.koin.android.ext.android.get

/**
 * @author xlh
 * @date 2019/10/14.
 */
class ParamsInterceptor(private val deviceInfoRepository: DeviceInfoRepository) : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {

        var request = chain.request()

        val builder = request.newBuilder()

        if (deviceInfoRepository.sn.isNotEmpty()) {
            Log.e("ysj",deviceInfoRepository.sn)
            builder.addHeader("serialNo", deviceInfoRepository.sn)
        }

        request = builder.build()
        return chain.proceed(request)
    }
}
